package thread;

import com.sun.javaws.IconUtil;

import static java.lang.Thread.sleep;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Ap0stoL2
 * Date: 2023-07-22
 * Time: 8:09
 */

//官方的Thread来自java.lang这个包,java.lang比较特殊,这里的类不需要手动import,可以默认使用
class MyThread extends Thread{

    @Override
    public void run() {

        while(true){
            System.out.println("i am thread");
            try {
                Thread.sleep(5000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }

    }

}
public class Demo1 {
    public static void main(String[] args) throws InterruptedException {
        MyThread myThread = new MyThread();
        myThread.start();

        while (true){
            System.out.println("i am main");
            Thread.sleep(5000);
        }
    }
}
